import re


def camel_to_snake(name: str) -> str:
    """将驼峰命名转换为蛇形命名（CamelCase → snake_case）"""
    name = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
    return re.sub('([a-z0-9])([A-Z])', r'\1_\2', name).lower()


def snake_to_camel(name: str) -> str:
    """将蛇形命名转换为驼峰命名（snake_case → CamelCase）"""
    components = name.split('_')
    return ''.join(x.title() for x in components)
